<template>
    <div id='' class='root_home'>
        <!-- 加载中... -->
    </div>
</template>
<script>
import loading from '@/assets/loading/loading.webp'
var async = require("async");
export default {
    name: '',
    props: [''],
    data() {
        return {
            loading: loading
        };
    },
    components: {},
    computed: {},
    beforeMount() { },
    mounted() {
        this.systemSet()
    },
    methods: {
        systemSet() {
            // 需要判断用户类型，如果是一级用户，系统默认超级管理员，则直接进入系统设置中，否则视为普通用户，进入模块系统导航中。
            // let userType = '租户'; // 租户、普通用户
            let userinfo = icu.storage.getData('userInfo');
            let userType = userinfo.superAdmin == '0' && userinfo.superTenant == '0' ? '普通用户' : '租户'; // 租户、普通用户
            const roleMap = {
                '租户': () => {
                    this.$Spin.show();
                    this.toSystem()
                },
                '普通用户': () => {
                    this.$router.replace('/center/fontApp')
                }
            }
            roleMap[userType] ? roleMap[userType]() : console.log("此人比较神秘！");
        },
        toSystem() {
            let _this = this;
            async.waterfall([function (callback) {
                _this.$http.$get('LoginUserSystemMenu', { params: { systemId: '' } }).then(res => {
                    if (res.code == 200) {
                        icu.storage.setData([
                            {
                                key: 'menuHeader',
                                value: res.data.menuHeader
                            },
                            {
                                key: 'menuSider',
                                value: res.data.menuSider
                            }
                        ]);
                        callback(null, name)
                    }
                })
                // 模拟菜单获取
                // _this.$http.$get('loadMenu', { params: {},baseUrl:'mockService' }).then(res => {
                //     if (res.code == 200) {
                //         icu.storage.setData([
                //             {
                //                 key: 'menuHeader',
                //                 value: res.data.header
                //             },
                //             {
                //                 key: 'menuSider',
                //                 value: res.data.sider
                //             }
                //         ]);
                //         callback(null, name)
                //     }
                // })
            }], function (err, result) {
                // setTimeout(() => {
                _this.$Spin.hide();
                _this.$router.push({
                    name: 'main'
                })
                _this.moreSize()
                // }, 1000);
            })
        },
        moreSize() {
            var allStrings = '';
            for (var key in icu.storage.localStorage) {
                if (icu.storage.localStorage.hasOwnProperty(key)) {
                    allStrings += icu.storage.localStorage[key];
                }
            }
            let msg = allStrings ? 3 + ((allStrings.length * 16) / (8 * 1024)) + ' KB' : 'Empty (0 KB)'
            icu.log.capsule('localStorage使用：', msg, 'warning')
        }
    },
    watch: {}
}
</script>
<style lang='less' scoped>
.root_home {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    height: 100%;
}
</style>